package com.cp.dao;

import com.cp.repository.WordFrqMi;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WordFrqMiMapper {

	@Select("SELECT * FROM word_frq_mi WHERE conviction_id = #{convictionId} AND class_relation_id = #{classRelationId}")
	@Results({
			@Result(id = true, property = "id", column = "id"),
			@Result(property = "content", column = "content"),
			@Result(property = "score", column = "score"),
			@Result(property = "conviction", column = "conviction_id", one = @One(select = "com.cp.dao.ConvictionMapper.getById")),
			@Result(property = "classRelation", column = "class_relation_id", one = @One(select = "com.cp.dao.ClassRelationMapper.getById"))
	})
	List<WordFrqMi> getByConvictionIdAndClassRelationId(@Param("convictionId") Integer convictionId, @Param("classRelationId") Integer classRelationId);


	@Select("SELECT DISTINCT(class_relation_id) FROM word_frq_mi WHERE conviction_id = #{convictionId}")
	@Results({
		@Result(property = "classRelation", column = "class_relation_id", one = @One(select = "com.cp.dao.ClassRelationMapper.getById"))
	})
	List<WordFrqMi> getByConvictionId(Integer convictionId);

}
